java - 将 TypeScript 转换为 Java
全部标签 我正在尝试使用TypeScript中先前设置的变量的值动态访问类的方法。类似的东西:classFoo{bar(){}}varmethodName="bar";varfooBar=newFoo();fooBar.methodName();//IwouldlikethistoresolvetofooBar.bar();例如,在PHP中我可以执行以下操作:classFoo{publicfunctionbar(){}}$methodName="bar";$fooBar=newFoo();$fooBar.$methodName();//resolvestofooBar.bar();谁知道这是否可
声明declaremodule"MyModule"{exportfunctionFoo(){...}exportfunctionBar(){...}}我只需要Foo某处,我应该如何导入它?import*asMyModulefrom"MyModule";MyModule.Foo();或import{Foo}from"MyModule";Foo()哪个比另一个好?以第一种方式导入所有导出是否有任何性能影响?我在发布问题之前阅读的一些引用资料:https://www.exratione.com/2015/12/es6-use-of-import-property-from-module-is
我的意图是有这样的目录结构:-/my-project/--/src/(hereareall.tsxfileslocated)--/dist/-index.html-/build/-bundle.js--/node_modules/--package.json--tsconfig.json--webpack.config.js所以,我想要我的index.html,它是在/dist子目录中手动创建的,在它里面我想要/buildsubdir,webpack制作的app.js所在的位置。我希望当我保存一些位于我的/src目录中的.tsx文件时,webpack会自动重建app.js并且webpa
我正在尝试使用taggedtemplateliteral带有typescript的ES5,但似乎typescript没有完全支持它。我有以下代码。classTemplateLiterals{age:number=24;name:'LukeSkywalker'privatetag(strings:string[],personExp,ageExp):string{varstr0=strings[0];//"that"varstr1=strings[1];//"isa"varageStr;if(ageExp>99){ageStr='centenarian';}else{ageStr='yo
我有一个简单的react-redux驱动的表单。我希望有一个form.container.tsx和一个form.component.tsx,其中form.container.tsx包含与redux状态减去Field的所有连接。我试图将我的容器包装在react-redux的连接中,然后将reduxForm包装在其中,看起来像TypeScript,redux-formandconnect:(理想)form.container.tsx:interfaceDummyFormContainerProps{}exportconstDummyFormContainer:React.SFC=props
我想将Javascript日期格式转换为ASP.NET日期格式。2012-09-1012:00PMto/Date(1347442050050-0700)/因为我要把它传回服务器。我从服务器上的请求中获取了ASP.NET格式,然后使用moment.js将其转换为Javascript日期:moment("/Date(1347442050050-0700)/").format("YYYY-MM-DDhh:mmA");有办法吗? 最佳答案 我得到了我需要的。如果这在某种程度上是错误的,请发表评论。vartest=moment("2012-0
我愿意:导入定义类的js文件:./myClass/index.js在某处声明MyClass的公共(public)方法(在index.ts或指定的声明文件中,我真的不知道该怎么做)有一个公开类的typescript文件:index.ts有点像//index.tsimportMyClassfrom'./myClass'//orrequire,oranythingthatwouldworkexport{MyClass}和//myClass/index.jsexportdefaultclassMyClass{...}这显然是行不通的,因为./myClass/index的导入将找不到模块。问题是
我开始使用Typescript2.5,现在我在Angulartypescript定义文件中收到以下代码消息:interfaceIHttpPromiseextendsIPromise{success(callback:IHttpPromiseCallback):IHttpPromise;error(callback:IHttpPromiseCallback):IHttpPromise;then(successCallback:(response:IHttpPromiseCallbackArg)=>IPromise,errorCallback?:(response:IHttpPromise
我正在尝试转换我们可以从iOS设备检索的视频url,并将其转换为ionic3中的BASE64,但我无法实现BASE64url。iOS视频URL:filePath=/var/mobile/Containers/Data/Application/3436A7EB-4684-4618-8125-3E6AE1645FCE/Documents/MUS_RA/1534429730643_capturedvideo.MOV我尝试了以下代码,通过使用BASE64cordova插件将视频URL转换为BASE64,但没有成功this.base64.encodeFile(filePath).then((
我有一个使用gulp的项目。我想将typescript文件转换为javascript并拥有源map。这是我现在拥有的:varsourcemaps=require('gulp-sourcemaps');vartypescript=require('gulp-typescript');gulp.task('typescript',function(){gulp.src('app/**/*.ts').pipe(typescript()).pipe(sourcemaps.init()).pipe(sourcemaps.write()).pipe(gulp.dest('app'))});这部分有